package vn.demand.dragon.model.business
{
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.http.HTTPService;

	public class LoadQuotationsDelegate 
	{
		private var responder : IResponder;
		private var service : HTTPService;

		public function LoadQuotationsDelegate( responder : IResponder ) 
		{
			// constructor will store a reference to the service we're going to call
			this.service = new HTTPService();
			this.service.url = "http://dev.dragon.com/index.php?m=quotations&a=quote_search&suppressHeaders=1";
//			this.service.url = "data/quote_search.xml";
			this.service.method = 'POST';
			this.service.resultFormat = 'e4x';
			
			// and store a reference to the proxy that created this delegate
			this.responder = responder;
		}

		public function loadQuotationService(params:Object = null) : void 
		{
			if (params == null) {
				params = new Object();
			}
//			params.m = 'quotations';
//			params.a = 'quote_search';
//			params.suppressHeaders = '1';
			// call the service
			var token:AsyncToken = service.send(params);
			
			// notify this responder when the service call completes
			token.addResponder( responder );
		}
	}
}